
export default (reducer,preloadedState,enhancer) => {
  let state = preloadedState;
  let subscribers = []
  const dispatch = (action) => {
    state = reducer(state,action)
    subscribers.forEach(item=>item())
  }
  const getState = ()=>{
    return state
  }
  const subscribe = (func)=>{
    subscribers.push(func)
  }
  dispatch()
  return {
    getState,
    subscribe,
    dispatch,
  }
}